﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using eShop.Core;
namespace eShop.Services
{
    /// <summary>
    /// s少data层
    /// </summary>
    public class AdminStock
    {
        #region 仓库字典处理类

        public static void CreateStock(StockInfo StockInfo)
        {
            int ret = eShop.Core.BSPData.RDBS.CreateStock(StockInfo);
            if (ret > 0)
            {

            }
        }


        public static DataTable AdminGetStockList()
        {
            return eShop.Core.BSPData.RDBS.GetStockList();
        }

        public static int DeleteStockByid(int wid)
        {
            return eShop.Core.BSPData.RDBS.DeleteStockById(wid);
        }


        public static void UpdateStock(StockInfo info)
        {
            eShop.Core.BSPData.RDBS.UpdateStock(info);
        }

        #endregion




        #region Receive
        public static DataTable AdminGetReceiveList()
        {
            return eShop.Core.BSPData.RDBS.GetReceiveList();
        }

        public static int DeleteReceiveByid(int receiveid)
        {
            return eShop.Core.BSPData.RDBS.DeleteReceiveById(receiveid);
        }

        public static int CreateReceive(ReceiveInfo receiveInfo)
        {
            int ret = eShop.Core.BSPData.RDBS.CreateReceive(receiveInfo);

            return ret;
        }

        public static int UpdateReceive(ReceiveInfo receiveInfo)
        {
          return  eShop.Core.BSPData.RDBS.UpdateReceive(receiveInfo);
        }


        public static ReceiveInfo GetReceiveByid(int rid)
        {
            ReceiveInfo receiveInfo = null;
            IDataReader reader = eShop.Core.BSPData.RDBS.GetReceiveById(rid);
            if (reader.Read())
            {
                receiveInfo = new ReceiveInfo();

                receiveInfo.ReceiveId = TypeHelper.ObjectToInt(reader["receiveid"]);
                receiveInfo.ReceiveNo = reader["receiveno"].ToString();
                receiveInfo.PId = TypeHelper.ObjectToInt(reader["pid"]);
                receiveInfo.StockId = TypeHelper.ObjectToInt(reader["stockid"]);
                receiveInfo.ReceiveNum = TypeHelper.ObjectToInt(reader["receivenum"]);
                receiveInfo.ReceiveDate = TypeHelper.ObjectToDateTime(reader["receivedate"]);
                receiveInfo.Remark = reader["remark"].ToString();
                receiveInfo.DoPerson = reader["doperson"].ToString();
            }

            reader.Close();
            return receiveInfo;
        }


        #endregion



    }
}
